package com.example.doer.reading;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.ab.fragment.AbFragment;

import java.util.ArrayList;
import java.util.List;

public class FragmentThree extends AbFragment {
    private FragmentManager fragmentManager;
    private TabLayout.Tab one;
    private TabLayout.Tab two;
  public FragmentThree(FragmentManager f){
      this.fragmentManager=f;
  }

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_three,container,false);

        Fragment messageFragment= new MessageFragment();
        Fragment chatFragment=new ChatListFragment();

        List<Fragment> list=new ArrayList<Fragment>();
        list.add(messageFragment);
        list.add(chatFragment);

        ViewPager viewPager =(ViewPager)view.findViewById(R.id.viewpager_mes);
        MyFragmentAdapter myFragmentAdapter=new MyFragmentAdapter(list,fragmentManager);
        viewPager.setAdapter(myFragmentAdapter);

        TabLayout tabLayout=(TabLayout)view.findViewById(R.id.tabLayout_mes);
        tabLayout.setupWithViewPager(viewPager);
        one=tabLayout.getTabAt(0);
        two=tabLayout.getTabAt(1);
        one.setText("消息");
        two.setText("私信");

        return view;
    }
}
